***                                                                                                                                                                                                                                                       
***                                                                                                                                                                                                                                                       
*** This Program already converted to Y2K                                                                                                                                                                                                                 
*** S&T Departement     on 29 April 1999 by Ben.Rahman                                                                                                                                                                                                    
***                                                                                                                                                                                                                                                       
***                                                                                                                                                                                                                                                       
set cent on                                                                                                                                                                                                                                               
*rest from n:report ADDI                                                                                                                                                                                                                                  
*TGL=PRITGL+1                                                                                                                                                                                                                                             
*if tgl=date()                                                                                                                                                                                                                                            
*   save all like pri* to n:report                                                                                                                                                                                                                        
*   return                                                                                                                                                                                                                                                
*endif                                                                                                                                                                                                                                                    
*INV=PRIBEG                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                          
tgl=date()-1                                                                                                                                                                                                                                              
do while .t.                                                                                                                                                                                                                                              
   @ 10, 48 SAY 'Transaction Date : ' get tgl pict '99/99/9999'                                                                                                                                                                                           
   read                                                                                                                                                                                                                                                   
   if tgl>=date()                                                                                                                                                                                                                                         
      loop                                                                                                                                                                                                                                                
   endif                                                                                                                                                                                                                                                  
   exit                                                                                                                                                                                                                                                   
enddo                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                          
IF MONTH(DATE())<>MONTH(TGL)                                                                                                                                                                                                                              
   DR1='Q:'                                                                                                                                                                                                                                               
ELSE                                                                                                                                                                                                                                                      
   DR1='n:'                                                                                                                                                                                                                                               
ENDIF                                                                                                                                                                                                                                                     
DR2='N:'                                                                                                                                                                                                                                                  
F1='NON_INVP'                                                                                                                                                                                                                                             
SELE 1                                                                                                                                                                                                                                                    
SET EXCLU OFF                                                                                                                                                                                                                                             
USE &DR1&F1                                                                                                                                                                                                                                               
SELE 1                                                                                                                                                                                                                                                    
TANGGAL=DATE()                                                                                                                                                                                                                                            
store 0 to pl1,pl2,pl3                                                                                                                                                                                                                                    
do while pl1=0                                                                                                                                                                                                                                            
   @ 12,60 say '/'                                                                                                                                                                                                                                        
   @ 12,54 prompt 'Print'                                                                                                                                                                                                                                 
   @ 12,62 prompt 'Quit'                                                                                                                                                                                                                                  
   menu to pl1                                                                                                                                                                                                                                            
   if pl1=2                                                                                                                                                                                                                                               
      RETN=.T.                                                                                                                                                                                                                                            
      return                                                                                                                                                                                                                                              
   else                                                                                                                                                                                                                                                   
      @ 14,60 say '/'                                                                                                                                                                                                                                     
      @ 14,46 prompt 'Printer Ready'                                                                                                                                                                                                                      
      @ 14,62 prompt 'Not Yet Ready'                                                                                                                                                                                                                      
      menu to pl2                                                                                                                                                                                                                                         
      if pl2=2                                                                                                                                                                                                                                            
         @ 14,46 clea to 14,78                                                                                                                                                                                                                            
         pl1=0                                                                                                                                                                                                                                            
      else                                                                                                                                                                                                                                                
         @ 16,46 say '        Printing...    '                                                                                                                                                                                                            
         set console off                                                                                                                                                                                                                                  
         set devi to prin                                                                                                                                                                                                                                 
      endif                                                                                                                                                                                                                                               
   endif                                                                                                                                                                                                                                                  
enddo                                                                                                                                                                                                                                                     
br=100                                                                                                                                                                                                                                                    
STORE 0 TO fl,hl,ttl,TTL1                                                                                                                                                                                                                                 
set devi to Print                                                                                                                                                                                                                                         
@ 0,0 say chr(15) pict 'x'                                                                                                                                                                                                                                
SELE 1                                                                                                                                                                                                                                                    
Locate for date_cur=tgl                                                                                                                                                                                                                                   
DO WHILE .T.                                                                                                                                                                                                                                              
    IF .NOT. FOUND()                                                                                                                                                                                                                                      
       IF EOF()                                                                                                                                                                                                                                           
          EXIT                                                                                                                                                                                                                                            
       ELSE                                                                                                                                                                                                                                               
          continue                                                                                                                                                                                                                                        
          loop                                                                                                                                                                                                                                            
       ENDIF                                                                                                                                                                                                                                              
    ELSE                                                                                                                                                                                                                                                  
       if br>57                                                                                                                                                                                                                                           
          if fl>0                                                                                                                                                                                                                                         
             eject                                                                                                                                                                                                                                        
          else                                                                                                                                                                                                                                            
             fl=1                                                                                                                                                                                                                                         
          endif                                                                                                                                                                                                                                           
          hl=hl+1                                                                                                                                                                                                                                         
          @  2, 24 SAY CHR(27)+'G'                                                                                                                                                                                                                        
          @  2, 24 say 'REPORT  OF ABNORMALITIES IN INVOICING for '+dtoc(TGL)                                                                                                                                                                             
          @  2,24 SAY CHR(27)+'H'                                                                                                                                                                                                                         
          @  2,86 say hl pict "99"                                                                                                                                                                                                                        
          BR=4                                                                                                                                                                                                                                            
       endif                                                                                                                                                                                                                                              
       BR=BR+3                                                                                                                                                                                                                                            
       @ BR, 3 SAY PAT_FILCOD+"  "+PAT_CODTYP                                                                                                                                                                                                             
       KODE=PAT_FILCOD                                                                                                                                                                                                                                    
       @ BR, 13 SAY PAT_NAME                                                                                                                                                                                                                              
       @ BR, 31 SAY PAT_F_NAME                                                                                                                                                                                                                            
       @ BR, 50 SAY PAT_M_INIT                                                                                                                                                                                                                            
       @ BR, 60 SAY PAT_SEX                                                                                                                                                                                                                               
       F2='LA'+KODE+'.DBF'                                                                                                                                                                                                                                
       F3='ME'+KODE+'.DBF'                                                                                                                                                                                                                                
       F4='PH'+KODE+'.DBF'                                                                                                                                                                                                                                
       IF FILE("&DR2&F2")                                                                                                                                                                                                                                 
          BR=BR+2                                                                                                                                                                                                                                         
          @ BR,15 SAY "LABORATORY TESTS WERE ENTERED AT LAB. STATION AND NO INVOICE WAS RAISED"                                                                                                                                                           
          SELE 2                                                                                                                                                                                                                                          
          SET EXCLU OFF                                                                                                                                                                                                                                   
          USE &DR2&F2                                                                                                                                                                                                                                     
          GO TOP                                                                                                                                                                                                                                          
          DO WHILE .NOT. EOF()                                                                                                                                                                                                                            
             BR=BR+1                                                                                                                                                                                                                                      
             IF BR>60                                                                                                                                                                                                                                     
                if fl>0                                                                                                                                                                                                                                   
                   eject                                                                                                                                                                                                                                  
                else                                                                                                                                                                                                                                      
                   fl=1                                                                                                                                                                                                                                   
                endif                                                                                                                                                                                                                                     
                hl=hl+1                                                                                                                                                                                                                                   
                @  2, 24 SAY CHR(27)+'G'                                                                                                                                                                                                                  
                @  2, 24 say 'REPORT  OF ABNORMALITIES IN INVOICING for '+dtoc(TGL)                                                                                                                                                                       
                @  2,24 SAY CHR(27)+'H'                                                                                                                                                                                                                   
                @  2,86 say hl pict "99"                                                                                                                                                                                                                  
                BR=4                                                                                                                                                                                                                                      
             ENDIF                                                                                                                                                                                                                                        
             @ BR, 3 SAY PROC_NBER                                                                                                                                                                                                                        
             @ BR, 8 SAY AREA_CODE                                                                                                                                                                                                                        
             @ BR,10 SAY SUB_AREACO                                                                                                                                                                                                                       
             @ BR,12 SAY PRO_CODE                                                                                                                                                                                                                         
             @ BR,16 SAY SHRT_DESCR                                                                                                                                                                                                                       
             @ BR,44 SAY PROC_X                                                                                                                                                                                                                           
             @ BR,48 SAY TOT_PRICE                                                                                                                                                                                                                        
             @ BR,60 SAY PROC_PAY                                                                                                                                                                                                                         
             @ BR,72 SAY PROC_HL                                                                                                                                                                                                                          
             SKIP                                                                                                                                                                                                                                         
          ENDDO                                                                                                                                                                                                                                           
          USE                                                                                                                                                                                                                                             
          DELE FILE &DR2&F2                                                                                                                                                                                                                               
       ELSE                                                                                                                                                                                                                                               
          IF FILE("&DR2&F3")                                                                                                                                                                                                                              
             BR=BR+1                                                                                                                                                                                                                                      
             @ BR,15 SAY "INVOICE HAS BEEN PREPARED BUT NOT PRINTED AND CONSEQUENTLY, NOT REGISTERED"                                                                                                                                                     
             BR=BR+1                                                                                                                                                                                                                                      
             @ BR,15 SAY "MEDICAL PROCEDURES"                                                                                                                                                                                                             
             SELE 2                                                                                                                                                                                                                                       
             SET EXCLU OFF                                                                                                                                                                                                                                
             USE &DR2&F3                                                                                                                                                                                                                                  
             GO TOP                                                                                                                                                                                                                                       
             DO WHILE .NOT. EOF()                                                                                                                                                                                                                         
                BR=BR+1                                                                                                                                                                                                                                   
                IF BR>60                                                                                                                                                                                                                                  
                   if fl>0                                                                                                                                                                                                                                
                      eject                                                                                                                                                                                                                               
                   else                                                                                                                                                                                                                                   
                      fl=1                                                                                                                                                                                                                                
                   endif                                                                                                                                                                                                                                  
                   hl=hl+1                                                                                                                                                                                                                                
                   @  2, 24 SAY CHR(27)+'G'                                                                                                                                                                                                               
                   @  2, 24 say 'REPORT  OF ABNORMALITIES IN INVOICING for '+dtoc(TGL)                                                                                                                                                                    
                   @  2,24 SAY CHR(27)+'H'                                                                                                                                                                                                                
                   BR=4                                                                                                                                                                                                                                   
                   @  2,86 say hl pict "99"                                                                                                                                                                                                               
                   BR=4                                                                                                                                                                                                                                   
                ENDIF                                                                                                                                                                                                                                     
                @ BR, 3 SAY PROC_NBER                                                                                                                                                                                                                     
                @ BR, 8 SAY AREA_CODE                                                                                                                                                                                                                     
                @ BR,10 SAY SUB_AREACO                                                                                                                                                                                                                    
                @ BR,12 SAY PRO_CODE                                                                                                                                                                                                                      
                @ BR,16 SAY SHRT_DESCR                                                                                                                                                                                                                    
                @ BR,44 SAY PROC_X                                                                                                                                                                                                                        
                @ BR,48 SAY TOT_PRICE                                                                                                                                                                                                                     
                @ BR,60 SAY PROC_PAY                                                                                                                                                                                                                      
                @ BR,72 SAY PROC_HL                                                                                                                                                                                                                       
                SKIP                                                                                                                                                                                                                                      
             ENDDO                                                                                                                                                                                                                                        
             USE                                                                                                                                                                                                                                          
             DELE FILE &DR2&F3                                                                                                                                                                                                                            
             IF FILE("&DR2&F4")                                                                                                                                                                                                                           
                BR=BR+2                                                                                                                                                                                                                                   
                @ BR,15 SAY "PHARMACY"                                                                                                                                                                                                                    
                SELE 2                                                                                                                                                                                                                                    
                SET EXCLU OFF                                                                                                                                                                                                                             
                USE &DR2&F4                                                                                                                                                                                                                               
                GO TOP                                                                                                                                                                                                                                    
                DO WHILE .NOT. EOF()                                                                                                                                                                                                                      
                   BR=BR+1                                                                                                                                                                                                                                
                   IF BR>60                                                                                                                                                                                                                               
                      if fl>0                                                                                                                                                                                                                             
                         eject                                                                                                                                                                                                                            
                      else                                                                                                                                                                                                                                
                         fl=1                                                                                                                                                                                                                             
                      endif                                                                                                                                                                                                                               
                      hl=hl+1                                                                                                                                                                                                                             
                      @  2, 44 SAY CHR(27)+'G'                                                                                                                                                                                                            
                      @  2, 44 say 'REPORT  OF ABNORMALITIES IN INVOICING for '+dtoc(TGL)                                                                                                                                                                 
                      @  2,44 SAY CHR(27)+'H'                                                                                                                                                                                                             
                      @  2,86 say hl pict "99"                                                                                                                                                                                                            
                      BR=4                                                                                                                                                                                                                                
                   ENDIF                                                                                                                                                                                                                                  
                   @ BR, 3 SAY PHAR_NBER                                                                                                                                                                                                                  
                   @ BR, 8 SAY PHAR_CODE                                                                                                                                                                                                                  
                   @ BR,15 SAY PHAR_NAME                                                                                                                                                                                                                  
                   @ BR,40 SAY PHAR_TYPE                                                                                                                                                                                                                  
                   @ BR,56 SAY PHAR_X                                                                                                                                                                                                                     
                   @ BR,64 SAY SALE_PRICE                                                                                                                                                                                                                 
                   @ BR,76 SAY PHAR_PAY                                                                                                                                                                                                                   
                   @ BR,86 SAY PHAR_HL                                                                                                                                                                                                                    
                   SKIP                                                                                                                                                                                                                                   
                ENDDO                                                                                                                                                                                                                                     
                USE                                                                                                                                                                                                                                       
                DELE FILE &DR2&F4                                                                                                                                                                                                                         
             ENDIF                                                                                                                                                                                                                                        
          ELSE                                                                                                                                                                                                                                            
             BR=BR+1                                                                                                                                                                                                                                      
             @ BR, 15 SAY "NO INVOICE WAS PREPARED FOR THIS PATIENT"                                                                                                                                                                                      
             br=br+1                                                                                                                                                                                                                                      
          ENDIF                                                                                                                                                                                                                                           
       ENDIF                                                                                                                                                                                                                                              
       SELE 1                                                                                                                                                                                                                                             
       CONTINUE                                                                                                                                                                                                                                           
    ENDIF                                                                                                                                                                                                                                                 
ENDDO                                                                                                                                                                                                                                                     
if br>50                                                                                                                                                                                                                                                  
   eject                                                                                                                                                                                                                                                  
   hl=hl+1                                                                                                                                                                                                                                                
   @  2, 24 SAY CHR(27)+'G'                                                                                                                                                                                                                               
   @  2, 24 say 'REPORT  OF ABNORMALITIES IN INVOICING for '+dtoc(TGL)                                                                                                                                                                                    
   @  2,24 SAY CHR(27)+'H'                                                                                                                                                                                                                                
   @  2,86 say hl pict "99"                                                                                                                                                                                                                               
   BR=4                                                                                                                                                                                                                                                   
endif                                                                                                                                                                                                                                                     
@ br+2, 10 say "Copy # 1 : Dr. Inge"                                                                                                                                                                                                                      
@ br+3, 10 say "Copy # 2 : C. Bond"                                                                                                                                                                                                                       
@ br+4, 10 say "Copy # 3 : Billing"                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                          
*stor .t. to priabn                                                                                                                                                                                                                                       
*if priact .and. prirev .AND. PRIABN                                                                                                                                                                                                                      
*   PRIBEG=INV                                                                                                                                                                                                                                            
*   PRITGL=TGL                                                                                                                                                                                                                                            
*   priact=.f.                                                                                                                                                                                                                                            
*   prirev=.f.                                                                                                                                                                                                                                            
*   PRIABN=.F.                                                                                                                                                                                                                                            
*endif                                                                                                                                                                                                                                                    
*save all like pri* to n:report                                                                                                                                                                                                                           
EJECT                                                                                                                                                                                                                                                     
@ 0,0 SAY CHR(18) PICT 'X'                                                                                                                                                                                                                                
SET DEVI TO SCREEN                                                                                                                                                                                                                                        
CLOSE DATA                                                                                                                                                                                                                                                
CLOSE INDEX                                                                                                                                                                                                                                               
RETURN                                                                                                                                                                                                                                                    
